package Homework;

public class FizzBuzz {
	int num;
	static int start = 1;

	public FizzBuzz(int num) {
		super();
		this.num = num;
	}

	public void fizz(){
		if(start%3==0 && start%5!=0){			
			System.out.print("fizz ");
			start++;
		}
	}

	public void buzz(){
		if(start%5==0 && start%3!=0){			
			System.out.print("buzz ");
			start++;
		}
	}
	
	public void fizzbuzz(){
		if(start%3==0 && start%5==0){			
			System.out.print("fizzbuzz ");
			start++;
		}
	}
	
	public void number(){
		if(start%3!=0 && start%5!=0){			
			System.out.print(start);
			System.out.print(" ");
			start++;
		}
	}
	
	public synchronized void print(String mode){
		if(start>num){
			return;
		}
		if(mode.equals("number")){
			number();
		}else if(mode.equals("fizzbuzz")){
			fizzbuzz();
		}else if(mode.equals("buzz")){
			buzz();
		}else{
			fizz();
		}
	}
}
